home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 008a / paragen2.zip / VIDUTIL.C < prev    next >
C/C++ Source or Header  |  1991-03-28  |  3KB  |  168 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include <string.h>
  4. #include <conio.h>
  5. #include <dos.h>
  6. #include <ctype.h>
  7. #include "vlib.h"
  8. #include "vidlib.h"
  9.  
  10. void GoToRC(unsigned Row, unsigned Col) {
  11.  
  12.     union REGS InRegs,OutRegs;
  13.  
  14.     InRegs.h.ah = CUR_POS;
  15.     InRegs.h.bh = 0;
  16.     InRegs.h.dh = (Row-1) & 0xFF;
  17.     InRegs.h.dl = (Col-1) & 0xFF;
  18.  
  19.     int86(VIDEO_IO,&InRegs,&OutRegs);
  20.  
  21. }
  22.  
  23.  
  24. void ClearArea(unsigned Row,unsigned Col,unsigned NumRows,unsigned NumCols) {
  25.  
  26.     union REGS InRegs,OutRegs;
  27.  
  28.     InRegs.h.ah = SCROLL_UP;
  29.     InRegs.h.al = 0;
  30.     InRegs.h.bh = 7;
  31.     InRegs.h.bl = 0;
  32.     InRegs.h.ch = Row-1;
  33.     InRegs.h.cl = Col-1;
  34.     InRegs.h.dh = NumRows+1;
  35.     InRegs.h.dl = NumCols+1;
  36.     int86(VIDEO_IO,&InRegs,&OutRegs);
  37.  
  38.     
  39. }
  40.  
  41.  
  42. void DrawBox(unsigned Row,unsigned Col,unsigned NumRows,unsigned NumCols,char *Title) {
  43.     
  44.     unsigned Loop,Loop1;
  45.     static unsigned char BoxType[] = "╔╗═║╚╝";
  46.  
  47.  
  48.  
  49.     GoToRC(Row,Col);
  50.     printf("%c",BoxType[0]);
  51.     for (Loop = 0; Loop < NumCols-2; Loop++)
  52.         printf("%c",BoxType[2]);
  53.     printf("%c",BoxType[1]);
  54.  
  55.     for (Loop = 1; Loop < NumRows -1; Loop++) {
  56.         GoToRC(Loop+Row,Col);
  57.         printf("%c",BoxType[3]);
  58.         for (Loop1 = 0; Loop1 < NumCols-2; Loop1++)
  59.             printf(" ");
  60.         printf("%c",BoxType[3]);
  61.     }
  62.  
  63.     GoToRC(NumRows+Row-1,Col);
  64.     printf("%c",BoxType[4]);
  65.     for (Loop = 0; Loop < NumCols-2; Loop++)
  66.         printf("%c",BoxType[2]);
  67.     printf("%c",BoxType[5]);
  68.     CenterText(Row,Col,NumCols,Title);
  69.  
  70.  
  71. }
  72.  
  73. void PrintText(unsigned Row,unsigned Col,char *Title) {
  74.  
  75.     GoToRC(Row,Col);
  76.     printf("%s",Title);
  77.     
  78. }
  79.  
  80. void CenterText(unsigned Row,unsigned Col, unsigned Cols,char *Title) {
  81.  
  82.     GoToRC(Row,(Cols-(strlen(Title)))/2+Col);
  83.     printf("%s",Title);
  84.     
  85. }
  86.  
  87. char *GetString(unsigned Row,unsigned Col,unsigned Width,char *SValue,BOOLEAN UpperCase) {
  88.  
  89.     unsigned Index;
  90.     int Key;
  91.     static char TempString[80];
  92.  
  93.     memset(TempString,'\0',sizeof(TempString));
  94.     strcpy(TempString,SValue);
  95.  
  96.     GoToRC(Row,Col);
  97.     for (Index=0; Index < Width; Index++) {
  98.         Key = getch();
  99.         if (Key == 27) {
  100.             TempString[Index] = '\0';
  101.             if (UpperCase)
  102.                 return(strupr(SValue));
  103.             else
  104.                 return(SValue);
  105.         }
  106.         if (Key == 13 || Key == 10) {
  107.             if (Index != 0)
  108.                 TempString[Index] = '\0';
  109.             if (UpperCase)
  110.                 strcpy(SValue,strupr(TempString));
  111.             else
  112.                 strcpy(SValue,TempString);
  113.             return(SValue);
  114.         }
  115.         else {
  116.             if (UpperCase)
  117.                 printf("%c",toupper(Key));
  118.             else 
  119.                 printf("%c",Key);
  120.             TempString[Index] = Key;
  121.         }
  122.     }
  123.     TempString[Index] = '\0';
  124.     if (UpperCase)
  125.         strcpy(SValue,strupr(TempString));
  126.     else
  127.         strcpy(SValue,TempString);
  128.     return(SValue);
  129. }
  130.  
  131.  
  132.  
  133. void PrintFText(BOOLEAN GetChar,unsigned Row,unsigned Col, char *PrintFormat, ...) {
  134.  
  135.    char *ConvertedString;
  136.    char ConvertBuffer[80];
  137.    va_list Argp;
  138.     int Index;
  139.  
  140.    memset(ConvertBuffer,'\0',sizeof(ConvertBuffer));
  141.       ConvertedString = ConvertBuffer;
  142.    va_start(Argp,PrintFormat);
  143.     vsprintf(ConvertedString,PrintFormat,Argp);
  144.    va_end(Argp);
  145.  
  146.     GoToRC(Row,Col);
  147.     printf("%s",ConvertedString);
  148.     if (GetChar) {
  149.         getch();
  150.         GoToRC(Row,Col);
  151.         for (Index = 0; Index < strlen(ConvertedString); Index++)
  152.             printf(" ");
  153.     }
  154.  
  155. }
  156.  
  157. void ClearMessageArea(void) {
  158.  
  159.     char Spaces[80];
  160.     
  161.  
  162.     memset(Spaces,'\0',sizeof(Spaces));
  163.     memset(Spaces,' ',NUMSPACES);
  164.  
  165.     PrintText(23,5,Spaces);
  166.     PrintText(24,5,Spaces);
  167. }
  168.